package com.nineclock.sign.service.impl;

import com.nineclock.common.threadlocal.CurrentUserHolder;
import com.nineclock.common.utils.DateTimeUtil;
import com.nineclock.sign.service.SignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.Date;


@Service
@Slf4j
public class SignServiceImpl implements SignService {



    @Autowired
    RedisTemplate redisTemplate;



    @Override
    public Integer getDayCount() {
        String mobile = CurrentUserHolder.get().getMobile();


        String key = DateTimeUtil.dateToStr(new Date(), DateTimeUtil.TIME_FORMAT_2) + CurrentUserHolder.get().getMobile();
        String o = (String) redisTemplate.boundValueOps(key).get();


        if (o == null) {
            return 0;
        }
        return Long.valueOf(o).intValue();
    }
}
